Groovy WebServices for Groovy 1.6/1.8 (GroovyWS)

It is possible to call a web service from within Groovy code. See the following examples on how to do this. This feature only works with Java 1.6 or higher. If in doubt use this version.

 

Groovy code example

The following examples come from the groovyWS website. You can use the N4 ScriptRunner to test this groovy.

import groovyx.net.ws.WSClient

public class WebserviceTest {

public int execute() {

  println "Entering callWebservice method";

  WSClient proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader);

  proxy.initialize();

  Integer result = new Integer(proxy.CelsiusToFahrenheit(0));

  println "Leaving callWebservice method: Result="+result;

  return result;

}

}